@extends('welcome')
<link rel="stylesheet" href="/Home/User/css/safe/ms-style.min.css" />
<link rel="stylesheet" href="/Home/User/css/safe/personal_member.min.css" />
<link rel="stylesheet" href="/Home/User/css/safe/Snaddress.min.css" />
<link rel="stylesheet" href="/Home/login/css/landreg.css" />
<!--导入地区联动插件-->
<script type="text/javascript" src="/Home/UserEdit/jquery.js"></script>
<script type="text/javascript" src="/Home/UserEdit/area.js"></script>
<script type="text/javascript" src="/Home/UserEdit/location.js"></script>
@section('titletitle','我的订单--优品惠')

@section('zhong_content')
  <br/>
  <!-- 用户中心开始 -->
  <div id="ms-center" class="personal-member">
    <div class="cont">
      <div class="cont-side">
        <div class="side-neck">
          <i></i>
        </div>
        <div class="ms-side">
          <article class="side-menu side-menu-off">
            <dl class="side-menu-tree">
              <dt>订单管理</dt>
              <dd><a href="{{url('home/order/xiangqing')}}" target="_self" style="color:#f70"><span class="active"></span>订单中心</a></dd>
            </dl>
            <dl class="side-menu-tree">
              <dt>账户管理</dt>
              <dd><a href="{{url('home/user/edit')}}" target="_self"><span class="active"></span>我的资料</a></dd>
              <dd><a href="{{url('home/user/password')}}" target="_self"><span class="active"></span>密码修改</a></dd>
              <dd><a href="{{url('home/user/address')}}" target="_self"><span></span>地址管理</a></dd>
            </dl>
            <dl class="side-menu-tree">
              <dt>收藏管理</dt>
              <dd><a href="{{url('home/collect/index')}}" target="_self"><span class="active"></span>收藏列表</a></dd>
            </dl>
            <a ison="on" class="switch-side-menu icon-up-side"><i></i></a>
          </article>
        </div><article class="side-menu side-menu-off">
            <dl class="side-menu-tree">
              <dt>订单管理</dt>
              <dd><a href="{{url('home/user/index')}}" target="_self"><span class="active"></span>订单中心</a></dd>
            </dl>
            <dl class="side-menu-tree">
              <dt>账户管理</dt>
              <dd><a href="{{url('home/user/edit')}}" target="_self" style="color:#f70"><span class="active"></span>我的资料</a></dd>
              <dd><a href="{{url('home/user/password')}}" target="_self"><span class="active"></span>密码修改</a></dd>
              <dd><a href="{{url('home/user/address')}}" target="_self"><span></span>地址管理</a></dd>
            </dl>
            <dl class="side-menu-tree">
              <dt>收藏管理</dt>
              <dd><a href="{{url('home/collect/index')}}" target="_self"><span class="active"></span>收藏列表</a></dd>
            </dl>
            <a ison="on" class="switch-side-menu icon-up-side"><i></i></a>
          </article>
      </div>
      <div class="cont-main">
        <div class="main-wrap mt15">
          

          
          <h3>
            <strong>我的订单</strong>
          <span style="font-size:17px;color:green;">

          @if(session('success'))
            {{session('success')}}
          @endif  
          </span>
          </h3>
<?php 
                      $i = 0;
                   ?>
          <!-- 我的订单 -->
          @if($dingdanss == 0)
          <div style="padding-left:20px;font-size:14px">您还没有任何订单,请前往<a href="/" style="color:red;cursor:pointer" target="_self">首页</a>选择商品下单</div>
          @endif
          @if($dingdanss == 1)
           @foreach($orders as $k=>$v)
          <div class="container" style="width:1000px;margin-bottom:10px;border:1px #E9E9E9 solid;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box">
           <div class="row" style="width:998px;height:30px;background:#F7F7F7;">
              <div class="col-lg-1" style="height:30px;">
                <div style="width:60px;height:22px;background:#56ADFA;color:#FCFCFC ;text-align:center;line-height:22px;margin-top:5px;">网站订单</div>

              </div>
              <div class="col-lg-3" style="height:30px;">
                <div style="height:22px;text-align:center;line-height:22px;margin-top:5px;">订单编号：{{$v->dingdan_id}}</div>
              </div>     
              <div class="col-lg-4" style="height:30px;">
                <div style="height:22px;text-align:center;line-height:22px;margin-top:5px;">下单时间：{{date('Y-m-d H:i:s',$v->atime)}}</div>
              </div>          

           </div>
           <div class="row" style="line-height:80px;">
             <div class="col-lg-1" style="height:80px;line-height:80px;">
               <div style="height:60px;text-align:center;line-height:60px;"><img style="height:60px;" src="/uploads/{{$v->dingdan_pic}}" alt=""></div>
             </div>
              <div class="col-lg-3" style="height:80px;">
                <div class="row">
                  <div class="col-lg-12">
                    <div  style="height:22px;text-align:center;line-height:22px;">{{$v->dingdan_name}}</div></div>
                  <div class="col-lg-12">
                    <div style="height:22px;text-align:center;line-height:22px;">颜色：{{str_replace([1,2,3,4,5,6,7],['红色','黄色','蓝色','绿色','黑色','白色'],$v->dingdan_color)}}</div></div>      
                  <div class="col-lg-12">
                    <div style="height:22px;text-align:center;line-height:22px;">尺码：{{str_replace([1,2,3,4,5],['S','M','L','XL','XXL'],$v->dingdan_size)}}</div></div>      
               </div>
              </div>     
              <div class="col-lg-2" style="height:80px;">
                <div>价格: {{$v->price}}</div>
              </div>      
              <div class="col-lg-1" style="height:80px;">
                <div>数量: {{$v->dingdan_num}}</div>
              </div>
              <div class="col-lg-1" style="height:80px;border-left:1px #E9E9E9 solid;border-right:1px #E9E9E9 solid">
                <div class="row" style="margin-right:0px;margin-left:15px">
                  <div class="col-lg-12">
                    <div  style="height:22px;text-align:center;line-height:22px;">{{$v->price*$v->dingdan_num}}</div></div>
                  <div class="col-lg-12">
                    <div style="height:22px;text-align:center;line-height:22px;">(<span style="color:#0052CE">免运费</span>)</div></div>      
               
               </div>
              </div>
              <div class="col-lg-1" style="height:80px;">
                <div class="row">
                  <div class="col-lg-12 shezhi">
                    <input type="hidden" name="did" value="{{$v->id}}">
                    <div  style="height:22px;text-align:center;line-height:22px;color:red;"><a href="" target="_self" class="quxiao">@if($v->status != 3) 取消 @else 已取消 @endif</a></div>
                  </div>
    
                  <div class="col-lg-12">
                    <div style="height:22px;text-align:center;line-height:22px;">
                          <!-- <button class="btn btn-default" data-toggle="modal" data-target="#myModal" style="font-size:14px">查看详情</button> -->
                              <a data-toggle="modal" data-target="#myModal<?php echo $i;?>">查看详情</a>
                              <div class="modal fade" id="myModal<?php echo $i;?>"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog">
                                  <div class="modal-content">
                                    <div class="modal-header">
                                      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                      <h4 class="modal-title" id="myModalLabel">订单详情</h4>
                                    </div>
                                    <div class="modal-body">
                                            <!-- 订单详情 -->
                                   
                                            <div class="form-list tab-switch personal-wrap-show aa" style="">
                                                  <div class="row" style="">
                                                      <div class="col-lg-12" >
                                                        <div class="col-lg-2" style="">订单详情</div>
                                                      </div> 
                                                      <div class="col-lg-12" style="">
                                                          <div class="col-lg-3">&nbsp;&nbsp;| 订单状态:</div>
                                                          <div class="col-lg-2">{{str_replace([1,2,3],['已付','未付','已取消'],$v->status)}}</div>
                                                      </div>
                                                  </div>
                                                  <div class="row">
                                                          <div class="col-lg-12" style="">
                                                            <div class="col-lg-2" style="">订单信息</div>

                                                          </div>
                                                          <div class="col-lg-12" style="">
                                                            <div class="col-lg-8" style="">&nbsp;&nbsp; 订单编号：{{$v->dingdan_id}}&nbsp; 下单时间：{{date('Y-m-d H:i:s',$v->atime)}}</div>
                                                          </div>
                                                          <div class="col-lg-12 addresses" style="">
                                                            <div class="col-lg-12 " style="">                          
                                                              <div class="col-lg-2">收货信息</div>
                                                              <div class="col-lg-2">{{$v->dizhi_name}}</div>
                                                              <div class="col-lg-8"><span class="add" add="{{$v->sheng}},{{$v->shi}},{{$v->xian}}"></span>{{$v->content}}</div>
                                                            </div>
                                                            <div class="col-lg-12" style="">
                                                              <div class="col-lg-2">支付方式:</div>
                                                              <div class="col-lg-2">{{str_replace([1,2],['在线支付','货到付款'],$v->zhifu_fangshi)}}</div>
                                                            </div>
                                                            <div class="col-lg-12" style="">
                                                               <div class="col-lg-2">配送商家:</div>
                                                               <div class="col-lg-8">优品惠官方网站</div>
                                                            </div>
                                                            <div class="col-lg-12" style="">
                                                              <div class="col-lg-2">买家留言:</div>
                                                              <div class="col-lg-8">工作日、双休日与节假日均可送货</div>
                                                            </div>
                                                            <div class="col-lg-12" style="">
                                                              <div class="col-lg-2">发票信息:</div>
                                                              <div class="col-lg-2">无 </div>
                                                            </div>   
                                                          </div>
                                                         <script type="text/javascript">
                                                            $(document).ready(function() {
                                                              showLocation();
                                                              //获取省市县信息并设置
                                                              $('.addresses .add').each(function(){
                                                                var str = $(this).attr('add');
                                                                var info = getInfo(str);
                                                                // alert(info);
                                                                $(this).html(info);
                                                              });
                                                              //定义获取城市信息方法
                                                              function getInfo(str){
                                                                //console.log(str);
                                                                //拆分字符串
                                                                var arr = str.split(',');
                                                                // console.log(arr);  
                                                                var ls  = new Location;
                                                                var l = ls.items;
                                                                // console.log(l['0,1,2']['5']);
                                                                var sheng = l['0'][arr[0]];
                                                                var shi = l['0,'+arr[0]][arr[1]];
                                                                var xian = l['0,'+arr[0]+','+arr[1]][arr[2]];
                                                                return sheng+shi+xian;
                                                              }
                                                            });
                                                         </script>             
                                                  </div>
                                            </div>
                                            <!-- 订单详情 end -->     
                                    </div>
                                  </div>
                                </div>
                              </div>
                    </div>
                  </div>      
                        
                </div>
              </div>
              <div class="col-lg-1" style="height:80px;border-left:1px #E9E9E9 solid;border-right:1px #E9E9E9 solid">
                <div style="height:22px;text-align:center;line-height:22px;">再次购买</div>
              </div>
              <div class="col-lg-1" style="height:80px;">
                <div style="height:22px;text-align:center;line-height:22px;"><span style="color:#0052CE;font-weight:bold;width:15px;">+</span>更多</div>
                <div style="height:22px;text-align:center;line-height:22px;"><span style="color:#0052CE;font-weight:bold;width:15px;">+</span><a href="{{url('/home/comment/index',['id'=>$v->dingdan_id])}}">评价</a></div>
              </div>
           </div>
          </div>
<?php 
$i++;

 ?>
           @endforeach
<div class="col-md-offset-4">
  
          {!! $orders->render() !!}
</div>
           @endif
          <!-- 我的订单 end -->
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- 用户中心结束 -->
@endsection
@section('myjs')
  <script type="text/javascript">
  // alert($);
  $('.quxiao').click(function(){
    // alert(22);
    var dd = $(this);
    var id = $(this).parents('.shezhi').find('input[name=did]').val();
    // alert(id);
    //发送ajax
    $.get("{{url('/home/order/zhuangtai')}}",{did:id},function(data){
            console.log(data);
            if(data == 1){
              alert('取消成功');
              dd.html('已取消');
            }else{
              alert('取消失败');
            }
    });
  })    
  </script>
@endsection